import {isDef} from "../../../shared/util";

export const nodeOperations = {

    /**
     *
     * @param {Node} child
     * @param {Node} parent
     */
    append: function (child, parent) {
        parent.appendChild(child);
    },

    /**
     *
     * @param {Node} element
     * @return {Node}
     */
    getParent: function (element) {
        return element.parentNode;
    },

    /**
     *
     * @param {Node} parent
     * @param {Node} child
     * @param {Node} refEle
     */
    insertBefore: function (parent, child, refEle) {
        isDef(refEle)
            ? parent.insertBefore(child, refEle)
            : parent.appendChild(child);
    },

    /**
     * @param {Node} parent
     * @param {Node} child
     */
    removeChild: function (parent, child) {
        parent.removeChild(child);
    },

};
